﻿@using PagedList.Mvc
@model PagedList.IPagedList<CubicFWNet.Data.ViewModal.OrderView>
@{
    //ViewBag.Title = "Index";
    var supplierName = ViewBag.SupplierName;
}
<section class="content-header">
    <h1>
        采购订单打印
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index", "Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("PurchasePrint", "Purchase")">采购订单打印</a></li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-sm-12">
            <div class="box box-solid">
                <div class="box-nav clearfix">
                    <div class="col-sm-12 col-md-9">
                        <button type="button" class="btn btn-primary" onclick="query();" title="查询"><i class="fa fa-search"></i>&nbsp;&nbsp;查询</button>
                        <a class="btn btn-default" onclick="javascript: window.location.reload();" title="刷新"><span class="glyphicon glyphicon-refresh"></span></a>
                    </div>
                    <div class="col-sm-12 col-md-3">
                        <div class="input-group">
                        </div>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <table class="footable table table-stripped table-bordered table-hover" id="footable">
                        <thead>
                            <tr>
                                <th data-sort-ignore="true">
                                    供应商
                                </th>
                                <th data-hide="phone,tablet" data-sort-ignore="true">
                                    状态
                                </th>
                                <th data-sort-ignore="true">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (null != Model)
                            {
                                foreach (var item in Model)
                                {
                                    <tr>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.SupplierName)
                                        </td>
                                        <td>
                                            @if (item.Status == 0)
                                            {
                                                @Html.Raw("未打印")
                                            }
                                            @if (item.Status == 1)
                                            {
                                                @Html.Raw("已打印")
                                            }
                                        </td>
                                        <td>
                                            @if (item.Status == 0)
                                            {
                                                <a class="btn bg-blue btn-xs" href="@Url.Action("PurchaseInfoPrint", "Purchase", new {id = item.Id})">打印</a>
                                            }
                                            @if (item.Status == 1)
                                            {
                                                <a class="btn bg-blue btn-xs" href="@Url.Action("PurchaseInfoPrint", "Purchase", new {id = item.Id})">查看</a>
                                            }
                                            
                                        </td>
                                    </tr>
                                }
                            }
                        </tbody>
                        @if (null != Model)
                        {
                            <tfoot>
                                <tr>
                                    <td colspan="8">
                                        每页 @Model.PageSize 条记录，共 @Model.PageCount 页，当前第 @Model.PageNumber 页
                                        @Html.PagedListPager(Model, page => Url.Action("PurchasePrint", new { page, supplierName }))
                                    </td>
                                </tr>
                            </tfoot>
                        }
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>

<!--查询对话框-->
<div class="modal" id="queryDlg" style="display: none">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">查询</h4>
            </div>
            <form class="form-horizontal" id="frmquery" action="@Url.Action("PurchasePrint", "Purchase")" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for=""> 供应商 </label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" id="supplierName" name="supplierName" value="@supplierName" />
                        </div>
                    </div>
                    @*<div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for=""> 上级模块</label>
                            <div class="col-sm-8">
                                <input type="hidden" name="ParentName" id="ParentName" />
                                <select class="form-control" type="select" id="ParentId" name="ParentId">
                                    <option value="">==请选择==</option>
                                    <option value="1">1</option>
                                </select>
                            </div>
                        </div>*@
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">查询</button>
                </div>
            </form>
        </div>
    </div>
</div>
@section Scripts {
    <script>
        $(document).ready(function () {
            $('#footable').footable();

            //日期控件
            /*$(".Timedatepicker").datepicker({
                autoclose: true,
                language: 'zh', //汉化
                format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
                minView: "month" //选择日期后，不会再跳转去选择时分秒
            });*/
            //$(".form_datetime").datetimepicker('setStartDate', date);//设置 初始时间(放在这个位置及顺序  固定)
            //$(".switch").click(function () {
            //alert("ok");
            //$(".datetimepicker-months table tr td span").attr("disabled", false);
            //$(".datetimepicker-months table tr td span").removeClass("disabled");
            //});
        });

        function query() {
            $('#queryDlg').modal();
        }

        function ToVerifyPurchase(tempId) {

            $.ajax({
                url: "@Url.Action("VerifyPurchase", "Purchase")",
                type: "post",
                data: {
                    pcId: tempId
                },
                dataType: "json",
                success: function (data) {
                    if (data.Status == "1") {
                        window.location.href = '@Url.Action("AddPurchase", "Purchase")?pcId=' + tempId + '&type=3';
                    } else {
                        $.modalAlert("该采购单的补单累计数量已大于申请数量，不可再补单", "success");
                    }

                },
                error: function () {

                }
            });
        }
    </script>
}





